package sort.sort;

public class SelectionSort extends Sort{
    @Override
    public void sort() {
        for (int end = array.length - 1; end > 1  ;end--) {
            int maxIndex = 0;
            for (int begin = 1; begin <= end; begin++) {
                if (cmp(array[maxIndex],array[begin]) < 0) {
                    maxIndex = begin;
                }
            }
            swap(maxIndex,end);
        }
    }
}
